

#include<vlc/vlc.h>
#include<iostream>
#include <unistd.h>

using namespace std;

int main() {
    libvlc_instance_t *instance_vlc;
    libvlc_media_player_t *mediaplayer_vlc;
    libvlc_media_t *media_vlc;

    libvlc_time_t time_play;
    int waittime = 20;
    unsigned int width, height = 255;

    instance_vlc = libvlc_new(0, NULL);
    // 本地视频
//    media_vlc = libvlc_media_new_path(instance_vlc, "test.mp4");
    // 网络视频
    media_vlc = libvlc_media_new_location(instance_vlc, "rtsp://182.145.195.237:8099/DevAor=51000000001317000031");

    mediaplayer_vlc = libvlc_media_player_new_from_media(media_vlc);

    libvlc_media_release(media_vlc);
    libvlc_media_player_play(mediaplayer_vlc);

    sleep(waittime);

    time_play = libvlc_media_player_get_length(mediaplayer_vlc);
    cout << "用时：" << time_play << endl;

    int resultStatus = -1 ;
    resultStatus = libvlc_video_get_size(mediaplayer_vlc,100,&width,&height);
    cout << " result Status: "<< resultStatus <<" W: " << width << " H: " << height << endl;

    sleep(time_play - waittime);


    libvlc_media_player_stop(mediaplayer_vlc);
    libvlc_media_player_release(mediaplayer_vlc);
    libvlc_release(instance_vlc);
    return 0;

}

